<template>
  <!-- 我的收藏 -->
  <div class="purse-body">
    <div class="details">
      <div class="details-title">
        账号与安全中心/<span style="color: #3894f8">账号管理</span>
      </div>
      <div class="title">账号信息</div>

      <div class="bind-body">
        <div class="bind-left">
          <p>手机号：</p>
          <p>邮箱：</p>
        </div>
        <div class="bind-cen">
          <p>18237742511</p>
          <p>15539990687@163.com</p>
        </div>
        <div class="bind-right">
          <p @click="handelSwitch(1)">更换</p>
          <p @click="handelSwitch(2)">更换</p>
        </div>
      </div>
      <div class="title">登陆操作记录</div>
      <!-- 表格 -->
      <div class="tabulation">
        <RecordsTable :tableData="tableData"></RecordsTable>
      </div>
      <!-- 分页 -->
      <div class="paging-body">
        <paging :pagingObj="pagingObj" @pageVal="pageVal"></paging>
      </div>

      <div class="title" style="margin-top: 40px">
        屏蔽企业
        <p @click="handelAdd">添加</p>
      </div>
      <!-- 表格 -->
      <div class="tabulation">
        <ShieldTable :tableData="tableData1"></ShieldTable>
      </div>
      <!-- 分页 -->
      <div class="paging-body">
        <paging :pagingObj="pagingObj" @pageVal="pageVal"></paging>
      </div>
    </div>
    <AddDi
      :dialogVisible="dialogVisible"
      @handleClose="handleClose"
      @handleUnderstand="handleUnderstand"
    ></AddDi>
    <SwitchDi
      :dialogSwitch="dialogSwitch"
      :topName="topName"
      @handleClose="handleClose"
      @handleUnderstand="handleUnderstand"
    ></SwitchDi>
  </div>
</template>

<script>
import paging from "../../../../components/paging.vue";
import RecordsTable from "./components/RecordsTable.vue";
import ShieldTable from "./components/ShieldTable.vue";
import AddDi from "./components/AddDi.vue";
import SwitchDi from "./components/SwitchDi.vue";
export default {
  data() {
    return {
      pagingObj: {
        currentPage: 1, //当前页
        pageSize: 10, // 一页显示多少个
        totalDevice: 10, //用户总数
      },
      tableData: [
        {
          time: "2016年05月02日10:20",
          ip: "2408:8220:6b20:c770:7490:5fc5:**:bae0",
          equipment: "xxxx(PC)",
          Controls: "手机验证码登录",
          status: "1",
        },
      ], // 表格数据
      tableData1: [
        {
          name: "北京埃米科技有限公司",
        },
      ], // 表格数据2
      dialogVisible: false, // 添加
      dialogSwitch: false, // 更换手机号/邮箱弹窗
      topName: "", // 弹窗名称
    };
  },
  components: { paging, RecordsTable, ShieldTable, AddDi, SwitchDi },
  methods: {
    // 点击更换手机号/邮箱
    handelSwitch(num) {
      // 1更换手机号 2更换邮箱
      // if(num == 1){
      //   this.topName = '手机号更换'
      // }else{
      //   this.topName = '电子邮箱更换'
      // }
      this.topName = num;
      this.dialogSwitch = true;
    },
    // 点击添加执行
    handelAdd() {
      this.dialogVisible = true;
    },
    // 关闭弹窗
    handleClose(val) {
      if (val == 1) {
        // 添加弹窗关闭
        this.dialogVisible = !this.dialogVisible;
      } else if (val == 2) {
        // 更换手机号/邮箱弹窗关闭
        this.dialogSwitch = !this.dialogSwitch;
      }
    },
    // 弹窗确认
    handleUnderstand(val) {
      if (val == 1) {
        // 添加弹窗确认
        this.dialogVisible = !this.dialogVisible;
      } else if (val == 2) {
        // 更换手机号/邮箱弹窗确认
        this.dialogSwitch = !this.dialogSwitch;
      }
    },
    pageVal(val) {
      this.pagingObj.currentPage = val;
    },
  },
};
</script>

<style scoped lang="less">
.purse-body {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  // 最上层div放 搜索框..
  .details {
    width: 93%;
    display: flex;
    flex-direction: column;
    // margin: auto;
    margin: 0 auto;
    div {
      // width: 100%;
      // height: 35px;
      line-height: 35px;
      display: flex;
      font-size: 14px;
      font-weight: 400;
    }
    .details-title {
      font-size: 17px;
      font-weight: 600;
      margin-top: 10px;
    }
    // 标题
    .title {
      font-size: 16px;
      font-weight: 600;
      margin-top: 20px;
      display: flex;
      position: relative;
      p {
        width: 70px;
        height: 28px;
        margin: auto;
        line-height: 28px;
        text-align: center;
        font-size: 13px;
        color: #ffffff;
        border-radius: 5px;
        background-color: #3894ff;
        position: absolute;
        right: 0;
      }
    }
    .bind-body {
      height: 70px;
      display: flex;
      .bind-left {
        width: 8%;
        height: 70px;
        display: flex;
        flex-direction: column;
      }
      .bind-cen {
        width: 30%;
        height: 70px;
        display: flex;
        flex-direction: column;
      }
      .bind-right {
        width: 10%;
        height: 70px;
        display: flex;
        flex-direction: column;
        p {
          width: 60px;
          height: 30px;
          line-height: 30px;
          font-size: 12px;
          background-color: #3894ff;
          margin: auto;
          color: #ffffff;
          text-align: center;
          border-radius: 5px;
        }
      }
    }
    // 分页
    .paging-body {
      width: 100%;
      height: 30px;
      display: flex;
      margin-top: 10px;
      margin-bottom: 10px;
      justify-content: flex-end;
    }
    // 表格
    .tabulation {
      width: 100%;
      margin-top: 10px;
    }
  }
}
</style>
